package org.simplextensions.ui.preferences.xml;

import javax.xml.bind.annotation.adapters.XmlAdapter;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

public class XmlDateAdapter extends XmlAdapter<String, Date> {

	private static final DateFormat df = new SimpleDateFormat("yyyy-MM-dd");

	@Override
	public String marshal(Date arg0) throws Exception {
		return df.format(arg0);
	}

	@Override
	public Date unmarshal(String arg0) throws Exception {
		return df.parse(arg0);
	}

}
